package org.micropayment.model;

import java.io.Serializable;
import java.util.Date;
import javax.persistence.Basic;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.Table;
import javax.persistence.Temporal;
import javax.persistence.TemporalType;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;

/**
 *
 * @author jj
 */
@Entity
@Table(name = "HistoricalMovement")
@NamedQueries({
    @NamedQuery(name = "HistoricalMovement.findAll", query = "SELECT h FROM HistoricalMovement h"),
    @NamedQuery(name = "HistoricalMovement.findById", query = "SELECT h FROM HistoricalMovement h WHERE h.id = :id"),
    @NamedQuery(name = "HistoricalMovement.findByDate", query = "SELECT h FROM HistoricalMovement h WHERE h.date = :date"),
    @NamedQuery(name = "HistoricalMovement.findByBalance", query = "SELECT h FROM HistoricalMovement h WHERE h.balance = :balance")})
public class HistoricalMovement implements Serializable {
    private static final long serialVersionUID = 1L;
    @Id
    @Basic(optional = false)
    @Column(name = "ID", nullable = false)
    @GeneratedValue(strategy = GenerationType.AUTO)
    private Integer id;
    @Basic(optional = false)
    @Column(name = "date")
    @Temporal(TemporalType.TIMESTAMP)
    private Date date;
    @Basic(optional = false)
    @Column(name = "balance")
    private long balance;
    @JoinColumn(name = "accountId", referencedColumnName = "id")
    @ManyToOne(optional = false)
    private Account accountId;

    public HistoricalMovement() {
    }

    public HistoricalMovement(Integer id) {
        this.id = id;
    }

    public HistoricalMovement(Integer id, Date date, long balance) {
        this.id = id;
        this.date = date;
        this.balance = balance;
    }

    public Integer getId() {
        return id;
    }

    public void setId(Integer id) {
        this.id = id;
    }

    public Date getDate() {
        return date;
    }

    public void setDate(Date date) {
        this.date = date;
    }

    public long getBalance() {
        return balance;
    }

    public void setBalance(long balance) {
        this.balance = balance;
    }

    public Account getAccountId() {
        return accountId;
    }

    public void setAccountId(Account accountId) {
        this.accountId = accountId;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (id != null ? id.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof HistoricalMovement)) {
            return false;
        }
        HistoricalMovement other = (HistoricalMovement) object;
        if ((this.id == null && other.id != null) || (this.id != null && !this.id.equals(other.id))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "org.micropayment.model.HistoricalMovement[id=" + id + "]";
    }

}
